//
//  HomePushRecommendViewCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/25.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "HomePushRecommendViewCell.h"

@interface HomePushRecommendViewCell ()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *currentLabel;
@property (nonatomic, strong) UILabel *originalPriceLabel;//原价

@end

@implementation HomePushRecommendViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = ColorFrom16(0xeef4f7);
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, GWIDTH , 116 - 10)];
        view.backgroundColor = ColorWhite;
        [self addSubview:view];
        
        _imgView = [UIImageView new];
        _imgView.backgroundColor = ColorCyan;
        [view addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(view).offset(10);
            make.left.equalTo(self).offset(10);
            make.width.equalTo(@86);
            make.height.equalTo(@86);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影（洋桥店）";
        _titleLabel.textColor = ColorFrom16(0x323232);
        _titleLabel.font = PFRFONT(16);
        [view addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(view).offset(8);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.right.equalTo(self).offset(-10);
            make.height.equalTo(@18);
        }];
        
        _nameLabel = [UILabel new];
        _nameLabel.text = @"洋桥／木樨园 2.3km";
        _nameLabel.textColor = ColorFrom16(0x7f7e7d);
        _nameLabel.font = PFRFONT(16);
        [self addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(12);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.width.greaterThanOrEqualTo(@156);//最小156
            make.height.equalTo(@18);
        }];
        
        _currentLabel = [UILabel new];
        _currentLabel.text = @"￥580";
        _currentLabel.textColor = ColorFrom16(0xff5b7a);
        _currentLabel.font = PFMFONT(18);
        [self addSubview:_currentLabel];
        [_currentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(11);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.width.greaterThanOrEqualTo(@47);
            make.height.equalTo(@20);
        }];
        
        _originalPriceLabel = [UILabel new];
        _originalPriceLabel.text = @"￥620";
        _originalPriceLabel.textColor = ColorFrom16(0x999999);
        _originalPriceLabel.attributedText = [GW_Tool setCutLine:_originalPriceLabel.text];
        _originalPriceLabel.font = PFMFONT(14);
        [self addSubview:_originalPriceLabel];
        [_originalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(15);
            make.left.equalTo(_currentLabel.mas_right).offset(10);
            make.width.greaterThanOrEqualTo(@38);
            make.height.equalTo(@16);
        }];

    }
    return self;
}

- (void)configViewWithModel:(HomeRecommendModel *)model
{
    _titleLabel.text = model.goods_name;
    _nameLabel.text = [NSString stringWithFormat:@"%@  %@", model.store_sadd, model.distance];
    _originalPriceLabel.text = [NSString stringWithFormat:@"￥%@", model.goods_price];
    _currentLabel.text = [NSString stringWithFormat:@"￥%@", model.sale_price];
    _originalPriceLabel.attributedText = [GW_Tool setCutLine:_originalPriceLabel.text];
    [_imgView sd_setImageWithURL:[NSURL URLWithString:STRING(model.goods_img)] placeholderImage:nil];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
